﻿using System;

namespace Puppy.Scheduler.Processors
{
    public static class TaskContextExtensions
    {
        /// <summary>
        /// 任务参数转换，优选取实例参数，如果为空取任务参数
        /// </summary>
        /// <param name="taskContext">任务上下文</param>
        /// <returns>实例/任务参数字符串</returns>
        public static string ParseParams(this TaskContext context)
        {
            if (!context.InstanceParams.IsNullOrWhiteSpace())
                return context.InstanceParams;

            return context.JobParams;
        }
    }
}
